<template>
  <fixed-bottom-button>
    <view class="progress">
      <view v-if="tipsCom" class="uni-btn-v large">
        <button class="width250" @click="returnPage">返回</button>
        <button v-if="active !== 4" @click="nextPage">继续</button>
        <button v-if="active === 4" @click="submitPage">提交</button>
      </view>
      <view v-else class="uni-btn-v">
        <button v-if="active !== 0" @click="proPage">上一题</button>
        <button @click="nextPage">提交</button>
      </view>
    </view>
  </fixed-bottom-button>
</template>

<script>
import fixedBottomButton from '@/components/fixedBottomBtn';
// 引入统计
import { tongji } from '@/utils/tools.js';
import { debounce } from '@/utils/optimize';
export default {
  components: {
    fixedBottomButton
  },
  props: {
    // 是否展示搜索按钮
    tipsCom: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {};
  },
  computed: {
    active() {
      return this.$store.getters.active;
    },
    assessForm() {
      return this.$store.getters.assessForm;
    }
  },
  methods: {
    // nextPage() {
    //   this.$emit('nextBtn');
    //   setTimeout(function () {
    //     wx.pageScrollTo({
    //       scrollTop: 0
    //     });
    //   }, 300);
    // },
    returnPage() {
      this.$store.commit('assessQuestion/SET_AJAXRES', false);
    },
    /* eslint-disable */
    nextPage: debounce(
      function () {
        tongji('b357b6ff-4d3c-4a02-a182-c586965affc9');
        if (this.tipsCom) {
          this.$emit('iKnowBtn');
          return false;
        }
        this.$emit('nextBtn');
        // wx.pageScrollTo({
        //   scrollTop: 0
        // });
      },
      500,
      true
    ),
    proPage() {
      tongji('0ebb869f-18bf-4608-930a-1ff22f4d5bf2');
      this.$emit('proBtn');
    },
    submitPage() {
      tongji('a613e51e-89d3-48a4-9eee-4677136d0224');
      this.$emit('submitPage');
      // this.submitSick();
    }
  }
};
</script>
<style>
page {
  background: rgba(244, 244, 244, 1);
}
.uni-btn-v button {
  border: none !important;
}
button:after {
  border: none !important;
}
</style>
<style lang="scss">
.uni-btn-v {
  text-align: center;
  width: 715rpx;
  display: flex;
  align-items: center;
  justify-content: space-around;
  button {
    width: 262rpx;
    height: 80rpx;
    line-height: 80rpx;
    border: 2rpx solid rgba(0, 0, 0, 0);
    background: linear-gradient(236deg, #fe894d 0%, #ef3931 100%);
    opacity: 1;
    border-radius: 44rpx;
    color: #fff;
    font-size: 32rpx;
  }
}
.large {
  button {
    width: 360rpx;
  }
  .width250 {
    width: 250rpx;
  }
}
</style>
